/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.globalsolutionslt.controlador;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import sv.com.globalsolutionslt.entidades.Idioma;

/**
 *
 * @author karinaMelara
 */
@Stateless
public class IdiomaFacade extends AbstractFacade<Idioma> {
    @PersistenceContext(unitName = "BoldeDeTrabajoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public IdiomaFacade() {
        super(Idioma.class);
    }
    
    public List<Idioma> IdiomaActivo(Integer p) {
       
        List<Idioma> idiomas=null;

        try {        
        String sql = "SELECT i FROM Idioma i  WHERE i.idIdioma not in (SELECT ip.idIdioma.idIdioma FROM IdiomaPersona ip where ip.idPersona.idPersona="+p+")";           
        Query q = em.createQuery(sql);

        idiomas = q.getResultList();

        } catch (NoResultException e) {
                System.out.println("Sin resultados");
        }        
        return idiomas;
    }    
    
}
